import React, { PureComponent } from 'react'
import axios from 'axios';
import './index.scss';
import MainHeader from './components/MainHeader';
import Tuijian from './components/Tuijian'
import withRightNav1 from '../../components/hoc/withRightNav1';
import MiaoSha from './components/miaosha';

class Main extends PureComponent {
    constructor() {
        super();
        this.state = {
            tuijianList: [],
            swiperList: [],
            miaoshaObj: null
        }
    }
    componentDidMount() {
        axios.post("https://srv.hotkidceo.com/appapi/api/root-ceo-content/hpPageConfigure/pageList", { channelId: "C06022632001", memberKey: 33294872 }).then(res => {
            console.log(res);
            this.setState({
                tuijianList: res.data.data[10].configureAttributeList,
                swiperList: res.data.data[1].configureAttribute,
                miaoshaObj: res.data.data[5]
            })
        })
    }
    render() {
        let { tuijianList, swiperList, miaoshaObj } = this.state;
        let { history } = this.props;
        return (
            <div className='main'>
                {
                    swiperList.length !== 0 ? <MainHeader swiperList={swiperList} history={history} /> : ""
                }
                {
                    miaoshaObj !== null ? <MiaoSha miaoshaObj={miaoshaObj} /> : ""
                }
                <Tuijian tuijianList={tuijianList} />
            </div>
        )
    }
}
export default withRightNav1(Main);
